angular.module('starter.controllers', [])

.controller('LiveCtrl', function($scope,LiveService) {
      /*var rootEle = document.querySelector("allmap");
      var ele = angular.element(rootEle);*/

      //显示地图
     /* $scope.showMap = function(){
        ShowMap.showMap();
      }*/
})
    .controller('LiveBusCtrl', function($scope,$state,LiveService) {
        LiveService.getBus($scope);
        /*$scope.goNavigation = function(index){
            var coords = $scope.busList[index].coords;

        }*/
        $scope.serviceCates = [{id:0,name:'北京'},{id:1,name:'天津'}];
        $scope.ss = function($event){
            alert('ssssss');
            $event.preventDefault();
            //$event.stopPropagation();
            $state.go('tab.carInsure');
            alert('ssssss');
            alert('ssssss');
        }
    })
    .controller('LiveNavigationCtrl', function($scope,$stateParams,LiveService) {
        /*var rootEle = document.querySelector("allmap");
         var ele = angular.element(rootEle);*/

        //显示地图
        var coords = $stateParams.coords;
        var lname = $stateParams.lname;
        var city = $stateParams.city;
        var address = $stateParams.address;
        LiveService.showMap(coords.split(','),lname,city,address);
        /*$scope.goNavigation = function(index){
            var coords = $scope.busList[index].coords;

        }*/
    })

.controller('CarInsureCtrl', function($scope, CarInsure) {
  $scope.friends = CarInsure.all();
})

.controller('FriendDetailCtrl', function($scope, $stateParams, Friends) {
  $scope.friend = Friends.get($stateParams.friendId);
})

.controller('CommunityCtrl', function($scope,$rootScope, Clubs, SelfDrive) {

        //$scope.demo = 'carclub';
        $scope.setPlatform = function(p) {
            document.body.classList.remove('platform-ios');
            document.body.classList.remove('platform-android');
            document.body.classList.add('platform-' + p);
            $rootScope.demo = p;
        }

        $scope.clubs = Clubs.all();

        $scope.selfDrives = SelfDrive.all();
})

    .controller('ClubDetailCtrl', function ($scope, Clubs, $stateParams) {
        $scope.club = Clubs.get($stateParams.clubIndex);
    })

    .controller('SelfDriveCtrl', function ($scope, SelfDrive, $stateParams) {
        $scope.selfDrive = SelfDrive.get($stateParams.driveIndex);
    })

    .controller('MyCenterCtrl', function($scope) {
    });
